package objects;
import java.util.ArrayList;


public class MyShapeBuffers {
    ArrayList<MyShape> buffer;
    private int count = 0, in = 0, out = 0;
    private boolean flagF1, flagF2, flagF3, flagF4;
    MyShapeBuffers()
    {
    	flagF1 = true;
    	flagF2 = true;
    	flagF3 = true;
    	flagF4 = true;
    	buffer = new ArrayList<MyShape>();
    }
    public synchronized int getCount() {
    	//System.out.println("sprawdzam counter");
    	notify();
    	return count;
    }
    public synchronized void Put(MyShape ms) {
   //      System.out.println("Dodaje ");
         buffer.add(ms); 
         in = (in + 1) % buffer.size(); 
         count++; 
         notify(); 
    }

    public synchronized MyShape Get() {
         while (count == 0) 
         {
              try { wait(); }
              catch (InterruptedException e) { } 
              finally { } 
         } 
         MyShape ms = buffer.get(out); 
         buffer.remove(out);
         if(buffer.size()!=0) {
        	 out = (out + 1) % buffer.size();
         }
         count--;
      //   System.out.println("zjadam "); 
         notify(); 
         return ms;
    }

	public synchronized boolean isFlagF1() {
		return flagF1;
	}

	public void setFlagF1(boolean flagF1) {
		this.flagF1 = flagF1;
	}

	public boolean isFlagF2() {
		return flagF2;
	}

	public void setFlagF2(boolean flagF2) {
		this.flagF2 = flagF2;
	}

	public boolean isFlagF3() {
		return flagF3;
	}

	public void setFlagF3(boolean flagF3) {
		this.flagF3 = flagF3;
	}

	public boolean isFlagF4() {
		return flagF4;
	}

	public void setFlagF4(boolean flagF4) {
		this.flagF4 = flagF4;
	}
    
    
}
